package com.project.systemfront.service.impl;


import com.project.systemfront.mapper.ArtworkMapper;
import com.project.systemfront.pojo.Artwork;
import com.project.systemfront.pojo.vo.ArtworkVo;
import com.project.systemfront.service.IArtworkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 作品Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-01-20
 */
@Service
public class ArtworkServiceImpl implements IArtworkService
{
    @Autowired
    private ArtworkMapper artworkMapper;

    /**
     * 查询作品
     * 
     * @param id 作品主键
     * @return 作品
     */
    @Override
    public ArtworkVo selectArtworkById(Long id)
    {
        return artworkMapper.selectArtworkById(id);
    }

    /**
     * 查询作品列表
     * 
     * @param artwork 作品
     * @return 作品
     */
    @Override
    public List<Artwork> selectArtworkList(Artwork artwork)
    {
        return artworkMapper.selectArtworkList(artwork);
    }

    /**
     * 新增作品
     * 
     * @param artwork 作品
     * @return 结果
     */
    @Override
    public int insertArtwork(Artwork artwork)
    {
        artwork.setCreateTime(new Date());
        return artworkMapper.insertArtwork(artwork);
    }

    /**
     * 修改作品
     * 
     * @param artwork 作品
     * @return 结果
     */
    @Override
    public int updateArtwork(Artwork artwork)
    {
        artwork.setUpdateTime(new Date());
        return artworkMapper.updateArtwork(artwork);
    }

    /**
     * 批量删除作品
     * 
     * @param ids 需要删除的作品主键
     * @return 结果
     */
    @Override
    public int deleteArtworkByIds(Long[] ids)
    {
        return artworkMapper.deleteArtworkByIds(ids);
    }

    /**
     * 删除作品信息
     * 
     * @param id 作品主键
     * @return 结果
     */
    @Override
    public int deleteArtworkById(Long id)
    {
        return artworkMapper.deleteArtworkById(id);
    }


    @Override
    public void incrementCommentCount(Long artworkId) {
        artworkMapper.incrementCommentCount(artworkId);
    }

    @Override
    public void incrementFavoriteCount(Long artworkId) {
        artworkMapper.incrementFavoriteCount(artworkId);
    }

    @Override
    public void incrementLikeCount(Long artworkId) {
        artworkMapper.incrementLikeCount(artworkId);
    }

    @Override
    public void decrementFavoriteCount(Long id) {
        artworkMapper.decrementFavoriteCount(id);
    }

    @Override
    public void decrementLikeCount(Long id) {
        artworkMapper.decrementLikeCount(id);
    }
}
